<template>
	<view>
		<orange-fullloading :loadshow="loadings" text="加载中,请耐心等待..."></orange-fullloading>
		<view class="wrap">
			<u-navbar :is-fixed="true" :custom-back="goucneter" title="卡号管理" back-icon-name="arrow-left">
				<view class="slot-wrap greenbg heigh150">
					<view class="u-navbar-centent-slot"></view>
				</view>
			</u-navbar>
			<view class="cartbg">
				<view class="cartbutton">
					<view class="cartbuttonview " :class="cattab == 1 ? 'action' : ' '" @click="cart(1)">
						普通卡
					</view>
					<view class="cartbuttonview" :class="cattab == 2 ? 'action' : ' '" @click="cart(2)">
						超级卡
					</view>
				</view>
			</view>
			<view class="cartrow" v-if="cattab == 1">
				<view class="u-tabs-box">
					<u-tabs-swiper bg-color="#FFFFFF" activeColor="#0DA0FF" ref="tabs" :list="list" :current="current"
						@change="change" :is-scroll="false" swiperWidth="750"></u-tabs-swiper>
				</view>
				<!-- 普通卡 -->
				<view class="select-box">
					<view class="select-all">
						<u-checkbox-group @change="changeptradio">
							<u-checkbox v-model="selectAll[cattab-1][current]" active-color="#0DA0FF" shape="circle">
								全选
							</u-checkbox>
						</u-checkbox-group>
					</view>
					<view class="select--right">
						<text>已选</text>{{lengthL}}<text></text><text>项,</text>
						<text>共</text><text>{{totalNum}}</text><text>项,</text>
					</view>
				</view>
				<view class="search-box">
					<image class="ss-img"
						src="https://tongyongjiakao-1307163845.cos.ap-shanghai.myqcloud.com/used_img/ss.png">
					</image>
					<u-field class="search-input" v-model="ptsearchValue" :border-bottom="false" @input="handleptinput"
						placeholder="输入卡号搜索">
					</u-field>
					<text class="search" @click="handelSearchpt">搜索</text>
				</view>
				<swiper class="swiper-box" :current="swiperCurrent" @change="animationfinish">
					<swiper-item class="swiper-item">

						<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="reachBottom">

							<view class="lojiazai" v-if="jiazai == true">数据加载中。。。</view>
							<cartlist :kalist="kalist_new" :cattab="cattab-1" @send="childClick" :current="current"
								@childClick="childClick">
							</cartlist>
							<!-- <u-loadmore :status="loadStatus[0]" bgColor="#f2f2f2"></u-loadmore> -->
						</scroll-view>
						<view class="" style="height: 350rpx;width: 100%;">
						</view>
					</swiper-item>
					<swiper-item class="swiper-item">

						<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="reachBottom">

							<cartlist :kalist="kalist_no" :cattab="cattab-1" :current="current"
								@childClick="childClick" />
						</scroll-view>
						<view class="" style="height: 350rpx;width: 100%;">
						</view>
					</swiper-item>
					<swiper-item class="swiper-item">

						<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="reachBottom">

							<cartlist :kalist="kalist_yonged" :cattab="cattab-1" :current="current"
								@childClick="childClick"></cartlist>
						</scroll-view>
						<view class="" style="height: 350rpx;width: 100%;">
						</view>
					</swiper-item>
					<swiper-item class="swiper-item">

						<scroll-view scroll-y style="height: 100%;width: 100%;">

							<cartlist :kalist="kalist" :cattab="cattab-1" :current="current" @childClick="childClick" />
						</scroll-view>
						<view class="" style="height: 350rpx;width: 100%;">
						</view>
					</swiper-item>
				</swiper>
			</view>
			<!-- 超极 -->
			<view class="cartrow" v-if="cattab == 2">

				<view class="u-tabs-box">
					<u-tabs-swiper bg-color="#FFFFFF" activeColor="#0DA0FF" ref="tabss" :list="lists"
						:current="currents" @change="changes" :is-scroll="false" swiperWidth="750"></u-tabs-swiper>
				</view>
				<view class="select-box">
					<view class="select-all">
						<u-checkbox-group @change="changecjradio">
							<u-checkbox v-model="selectAll[cattab-1][currents]" active-color="#0DA0FF"
								shape="circle">全选</u-checkbox>
						</u-checkbox-group>
					</view>
					<view class="select--right">
						<text>已选</text><text>{{lengthL}}</text><text>项</text>
						<text>共</text><text>{{totalNum}}</text><text>项</text>
					</view>
				</view>
				<view class="search-box">
					<image class="ss-img"
						src="https://tongyongjiakao-1307163845.cos.ap-shanghai.myqcloud.com/used_img/ss.png">
					</image>
					<u-field class="search-input" v-model="cjsearchValue" :border-bottom="false" placeholder="输入卡号搜索"
						@input="handlecjinput" placeholder-style="{color: #0DA0FF;}">
					</u-field>
					<text class="search" @click="handelSearchcj">搜索</text>
				</view>

				<swiper class="swiper-box" :current="swiperCurrents" @change="animationfinishs">
					<swiper-item class="swiper-item">

						<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="reachBottom">
							<!-- <view class="lojiazai" v-if="jiazai == true">数据加载中。。。</view> -->
							<cartlist :kalist="superkalist_new" @childClick="childClick"></cartlist>
						</scroll-view>
						<view class="" style="height: 350rpx;width: 100%;">
						</view>
					</swiper-item>
					<swiper-item class="swiper-item">

						<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="reachBottom">

							<cartlist :kalist="superkalist_no" @childClick="childClick"></cartlist>
						</scroll-view>
						<view class="" style="height: 350rpx;width: 100%;">
						</view>
					</swiper-item>
					<swiper-item class="swiper-item">

						<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="reachBottom">

							<cartlist :kalist="superkalist_yonged" @childClick="childClick"></cartlist>

						</scroll-view>
						<view class="" style="height: 350rpx;width: 100%;">
						</view>
					</swiper-item>
					<swiper-item class="swiper-item">

						<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="reachBottom">

							<cartlist :kalist="superkalist" @childClick="childClick"></cartlist>
						</scroll-view>
						<view class="" style="height: 350rpx;width: 100%;">
						</view>
					</swiper-item>
				</swiper>
			</view>
		</view>

		<u-popup border-radius="20" v-model="attrlangshow" mode="center" width="600rpx" height="300rpx">
			<view class="attrsetting">
				<view class="arrtku">
					<text>是否备注此账号</text>
				</view>
				<view class="attrbutton">
					<button class="attrbuttonview font-30">确认</button>
					<button class="attrbuttonview font-30">取消</button>
				</view>
			</view>
		</u-popup>

		<!-- <view class="footer">
			<button class="footan font-30" @click="exportex()">
				<text>{{ $t('ucarts.导出Excel') }}</text>
			</button>
		</view> -->

	</view>
</template>

<script>
	//接口
	import {
		//wxlogin_api, //微信登陆接口
		//applelogin_api, //苹果一键登录接口
		jihuo_api, //卡号卡密撤回接口
		cartlist_api, //卡号卡密列表
		kaaction_api, //卡号卡密激活
		search_api, //搜素接口
	} from '@/api/index';

	import cartlist from '@/components/kahaolar/kahaolar.vue';


	export default {
		compontents: {
			cartlist
		},
		data() {
			return {
				lang: this.$i18n.locale,
				lengthL: 0,
				totalNum: null,
				cattab: 1, //显示季卡还是永久卡  1 季卡 2 永久卡
				productList: [{
					id: 1,
					status: true
				}, {
					id: 2,
					status: false
				}, {
					id: 3,
					status: true
				}, {
					id: 4,
					status: true
				}],
				checked: true,
				radiock: [true, true, false, true],
				orderList: [
					[],
					[],
					[],
					[]
				],

				kalist: [], //全部普通卡
				kalist_new: [], //最新卡密-普通
				kalist_no: [], //未使用-普通
				kalist_yonged: [], //已使用-普通
				superkalist: [], //全部超级卡
				superkalist_new: [], //最新卡密-超级卡
				superkalist_no: [], //未使用-超级卡
				superkalist_yonged: [], //已使用-超级卡
				list: [{
						name: "可销售"
					},
					{
						name: "未使用"
					},
					{
						name: "已使用"
					},
					{
						name: "全部卡密"
					}
				],
				current: 0,
				swiperCurrent: 0,
				tabsHeight: 0,
				dx: 0,
				arr: [],
				//第二个选项卡
				lists: [{
						name: "可销售"
					},
					{
						name: "未使用"
					},
					{
						name: "已使用"
					},
					{
						name: "全部卡密"
					}
				],
				currents: 0,
				swiperCurrents: 0,
				dxs: 0,
				loadStatus: ['loadmore', 'loadmore', 'loadmore', 'loadmore'],
				//弹出框是否显示
				attrlangshow: false,
				jiazai: false,
				chcktrue: true,
				chckfalse: false,
				loadings: true,
				ptradio: false,
				cjradio: false,
				ptsearchValue: "",
				cjsearchValue: "",
				ptkxs: 0, //普通可销售已选项
				selectAll: [
					[false, false, false, false],
					[false, false, false, false]
				],
				pageInfo: {
					page: 1,
					size: 5
				}
			};
		},
		onLoad(options) {
			var that = this;
			console.log('options', options)

			//演示
			if (options.attrlangshow == 'true') {
				that.attrlangshow = true;
			}

			if (options.type == undefined) {
				that.cattab = 1;
			} else {
				that.cattab = options.type;
			}
			that.cartlists();
			that.loadings = false

			//演示
			uni.getStorage({
				key: 'lang_key',
				success: function(res) {
					console.log(res.data);

					that.$i18n.locale = res.data;
				},
				fail() {}
			});
			that.list = [{
					name: this.$t('ucarts.可销售')
				},
				{
					name: this.$t('ucarts.未使用')
				},
				{
					name: this.$t('ucarts.已使用')
				},
				{
					name: this.$t('ucarts.全部卡密')
				}
			]

		},


		methods: {
			childClick(e, item, kalistData) {
				// this.arr.push(item)
				// let hh = this.arr.map(item => {
				// 	if (item.checks) return item;
				// })
				// let target = hh.filter(current => {
				// 	return current != undefined
				// })
				let numl = 0
				kalistData.forEach((item, index) => {
					if (item.checks == true) {
						numl += 1
					}

				})
				this.lengthL = numl
				if (kalistData.length == numl) {
					if (this.cattab == 1) {
						this.selectAll[this.cattab - 1][this.current] = true
					} else {
						this.selectAll[this.cattab - 1][this.currents] = true
					}
				} else {
					this.selectAll[this.cattab - 1][this.current] = false
					this.selectAll[this.cattab - 1][this.currents] = false
				}
			},
			handleptinput(e) {
				this.ptsearchValue = e
				console.log("value", e)
				if (this.ptsearchValue == "") {
					this.cartlists()
				}

			},
			handlecjinput(e) {
				// console.log("eeeee",e)
				this.cjsearchValue = e
				if (this.cjsearchValue == "") {
					this.cartlists()
					console.log("1111")
				}
			},
			//普通搜索
			handelSearchpt() {
				console.log("search", this.ptsearchValue, this.cattab, this.current, )
				let data = {}
				if (this.current == 3) {
					data = {
						kahao: this.ptsearchValue,
						kleixing: "0",
						pgIndex: 1,
						rowCount: this.pageInfo.size,
					}
				} else {
					data = {
						kahao: this.ptsearchValue,
						kleixing: "0",
						kstatus: this.current,
						pgIndex: 1,
						rowCount: this.pageInfo.size,
					}
				}

				this.https({
					url: search_api,
					method: 'POST',
					header: {
						'content-type': 'application/json'
					},
					data,
					success: res => {
						console.log("搜索cartList", res);
						for (let i = 0; i < res.card_list.rows.length; i++) {

							var yesno = Number(res.card_list.rows[i].kstatus);

							var checks = false;
							var dischecks = false;
							var disabled = false
							if (yesno == 0) {
								checks = false;
							} else if (yesno == 1) {
								checks = false;
								dischecks = true;
							} else if (yesno == 2) {
								checks = false;
								dischecks = true;
								disabled = true
							}
							if (yesno == 3) {
								checks = false;
								dischecks = true;
							}

							//console.log(dischecks);
							res.card_list.rows[i].checks = checks;

							res.card_list.rows[i].kchetrue = dischecks;

							res.card_list.rows[i].dischecks = disabled;
						}

						if (this.current == 0) {
							this.kalist_new = res.card_list.rows
							this.kalist_new.forEach((item, index) => {
								item.ktime = this.happenTimeFun(item.ktime)
								item.kxtime = this.happenTimeFun(item.kxtime)

							})
						}
						if (this.current == 1) {
							this.kalist_no = res.card_list.rows
							this.kalist_no.forEach((item, index) => {
								item.ktime = this.happenTimeFun(item.ktime)
								item.kxtime = this.happenTimeFun(item.kxtime)
							})
						}
						if (this.current == 2) {
							this.kalist_yonged = res.card_list.rows
							this.kalist_yonged.forEach((item, index) => {
								item.ktime = this.happenTimeFun(item.ktime)
								item.kxtime = this.happenTimeFun(item.kxtime)
							})
						}
						if (this.current == 3) {
							console.log("全部")
							this.kalist = res.card_list.rows
							this.kalist.forEach((item, index) => {
								item.ktime = this.happenTimeFun(item.ktime)
								item.kxtime = this.happenTimeFun(item.kxtime)
							})
						}


					},
					fail: err => {
						console.log(err);
						uni.hideLoading();
					}
				});

			},
			//超级搜索
			handelSearchcj() {
				console.log("search", this.cjsearchValue, this.cattab, this.currents, )
				let data = {}
				if (this.currents == 3) {
					data = {
						kahao: this.cjsearchValue,
						kleixing: "1",
						pgIndex: 1,
						rowCount: this.pageInfo.size,
					}
				} else {
					data = {
						kahao: this.cjsearchValue,
						kleixing: "1",
						kstatus: this.currents,
						pgIndex: 1,
						rowCount: this.pageInfo.size,
					}
				}

				this.https({
					url: search_api,
					method: 'POST',
					header: {
						'content-type': 'application/json'
					},
					data,
					success: res => {
						console.log("搜索cartList", res);
						for (let i = 0; i < res.card_list.rows.length; i++) {

							var yesno = Number(res.card_list.rows[i].kstatus);

							var checks = false;
							var dischecks = false;
							var disabled = false
							if (yesno == 0) {
								checks = false;
							} else if (yesno == 1) {
								checks = false;
								dischecks = true;
							} else if (yesno == 2) {
								checks = false;
								dischecks = true;
								disabled = true
							}
							if (yesno == 3) {
								checks = false;
								dischecks = true;
							}

							//console.log(dischecks);
							res.card_list.rows[i].checks = checks;

							res.card_list.rows[i].kchetrue = dischecks;

							res.card_list.rows[i].dischecks = disabled;
						}

						if (this.currents == 0) {
							this.superkalist_new = res.card_list.rows

							this.superkalist_new.forEach((item, index) => {
								item.ktime = this.happenTimeFun(item.ktime)
								item.kxtime = this.happenTimeFun(item.kxtime)
							})
						}
						if (this.currents == 1) {
							this.superkalist_no = res.card_list.rows
							this.superkalist_no.forEach((item, index) => {
								item.ktime = this.happenTimeFun(item.ktime)
								item.kxtime = this.happenTimeFun(item.kxtime)
							})
						}
						if (this.currents == 2) {
							this.superkalist_yonged = res.card_list.rows
							this.superkalist_yonged.forEach((item, index) => {
								item.ktime = this.happenTimeFun(item.ktime)
								item.kxtime = this.happenTimeFun(item.kxtime)
							})
						}
						if (this.currents == 3) {
							this.superkalist = res.card_list.rows
							this.superkalist.forEach((item, index) => {
								item.ktime = this.happenTimeFun(item.ktime)
								item.kxtime = this.happenTimeFun(item.kxtime)
							})
						}


					},
					fail: err => {
						console.log(err);
						uni.hideLoading();
					}
				});
			},
			//全选  普通
			changeptradio(evt) {
				// console.log(this.cattab, this.current, this.selectAll[this.cattab - 1].kxsAll)
				// 普通卡全选
				if (this.cattab == 1) {
					console.log("普通", this.cattab, this.current, this.selectAll[this.cattab - 1][this.current])
					//普通卡可销售
					if (this.current == 0) {
						// console.log(this.kalist_new);
						this.kalist_new.forEach((item, index) => {
							item.checks = this.selectAll[this.cattab - 1][this.current]
						})

						if (this.selectAll[this.cattab - 1][this.current]) {
							this.lengthL = this.kalist_new.length
						} else {
							this.lengthL = 0
						}
					}
					//普通卡已使用
					if (this.current == 1) {
						this.kalist_no.forEach((item, index) => {
							item.checks = this.selectAll[this.cattab - 1][this.current]
						})
						if (this.selectAll[this.cattab - 1][this.current]) {
							this.lengthL = this.kalist_no.length
						} else {
							this.lengthL = 0
						}
					}
					//普通卡已使用
					if (this.current == 2) {
						this.kalist_yonged.forEach((item, index) => {
							item.checks = this.selectAll[this.cattab - 1][this.current]
						})
						if (this.selectAll[this.cattab - 1][this.current]) {
							this.lengthL = this.kalist_yonged.length
						} else {
							this.lengthL = 0
						}
					}
					//普通卡全部卡号
					if (this.current == 3) {
						this.kalist.forEach((item, index) => {
							item.checks = this.selectAll[this.cattab - 1][this.current]
						})
						if (this.selectAll[this.cattab - 1][this.current]) {
							this.lengthL = this.kalist.length
						} else {
							this.lengthL = 0
						}
					}
				}

			},
			//全选 超级
			changecjradio(evt) {
				//超级卡全选
				if (this.cattab == 2) {
					console.log("超级", this.cattab, this.currents, this.selectAll[this.cattab - 1][this.currents])
					//超级卡可销售
					if (this.currents == 0) {
						this.superkalist_new.forEach((item, index) => {
							item.checks = this.selectAll[this.cattab - 1][this.currents]
						})
						if (this.selectAll[this.cattab - 1][this.currents]) {
							this.lengthL = this.superkalist_new.length
						} else {
							this.lengthL = 0
						}
					}
					//超级卡未使用
					if (this.currents == 1) {
						this.superkalist_no.forEach((item, index) => {
							item.checks = this.selectAll[this.cattab - 1][this.currents]
						})
						if (this.selectAll[this.cattab - 1][this.currents]) {
							this.lengthL = this.superkalist_no.length
						} else {
							this.lengthL = 0
						}
					}
					//超级卡已使用
					if (this.currents == 2) {
						this.superkalist_yonged.forEach((item, index) => {
							item.checks = this.selectAll[this.cattab - 1][this.currents]
						})
						if (this.selectAll[this.cattab - 1][this.currents]) {
							this.lengthL = this.superkalist_yonged.length
						} else {
							this.lengthL = 0
						}
					}
					//超级卡全部卡号
					if (this.currents == 3) {
						this.superkalist.forEach((item, index) => {
							item.checks = this.selectAll[this.cattab - 1][this.currents]
						})
						if (this.selectAll[this.cattab - 1][this.currents]) {
							this.lengthL = this.superkalist.length
						} else {
							this.lengthL = 0
						}
					}
				}
			},

			goucneter() {
				uni.reLaunch({
					url: './ucenter'
				})
			},
			exportex() {
				var that = this;

				// #ifdef MP-WEIXIN
				uni.showModal({
					title: '提示',
					content: '小程序无法支持excel导出功能，请用app',
					success: function(res) {
						if (res.confirm) {
							console.log('用户点击确定');
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
				// #endif
				// #ifdef APP-PLUS
				let doExport = require('@/js_sdk/LZN-exportExcel/exportExcel.js');
				let datalist = [];
				if (that.cattab == 1) {
					datalist = that.kalist;
				} else {
					datalist = that.superkalist;
				}
				console.log('datalist-=', datalist);
				if (datalist.length < 0) {
					uni.showModal({
						title: '提示',
						content: '暂无卡号卡密信息，无法导出！',
						success: function(res) {
							if (res.confirm) {
								console.log('用户点击确定');
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					});
					return false;
				}
				var dataexcel = [];
				var datas = [
					[{
							content: '卡号',
							color: 'blue',
							type: 'text',
							width: '200px',
							height: '25px',
							fontSize: '16px'
						},
						{
							content: '卡密',
							color: 'blue',
							type: 'text',
							width: '200px',
							height: '25px',
							fontSize: '16px'
						},
						{
							content: '状态',
							color: 'blue',
							type: 'text',
							width: '200px',
							height: '25px',
							fontSize: '16px'
						}
					]
				];
				for (let i = 0; i < datalist.length; i++) {
					//dataexcel[i] = [];
					var kstatus = datalist[i].kstatus;
					var kastatus = '';
					if (kstatus == 0) {
						kastatus = '可销售';
					}
					if (kstatus == 1) {
						kastatus = '已销售，未激活';
					}
					if (kstatus == 2) {
						kastatus = '已销售，已激活';
					}
					if (kstatus == 3) {
						kastatus = '禁用';
					}
					datas.push([{
							content: datalist[i].kahao,
							color: 'blue',
							type: 'text',
							width: '200px',
							height: '25px',
							fontSize: '16px'
						},
						{
							content: datalist[i].kami,
							color: 'blue',
							type: 'text',
							width: '200px',
							height: '25px',
							fontSize: '16px'
						},
						{
							content: kastatus,
							color: 'blue',
							type: 'text',
							width: '200px',
							height: '25px',
							fontSize: '16px'
						}
					]);
				}
				console.log('dataexcel=====', datas);

				doExport('kalist', datas, function(e) {
					//执行下载文件操作
					console.log(e);
					uni.showModal({
						title: '保存成功',
						content: '保存成功，请点击确定打开文件！',
						success: function(res) {
							if (res.confirm) {
								console.log('用户点击确定');
								uni.openDocument({
									filePath: e,
									showMenu: true,
									success: function(res) {
										console.log('打开文档成功');
									},
									fail: function(es) {
										var urlStr = encodeURI('file://' + e);
										plus.runtime.openURL(urlStr, function(err) {
											console.log(err)
											console.log(e);
											console.log(urlStr);
										});
										uni.showToast({
											title: '文件打开失败',
											duration: 2000
										});
									}
								});
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					});
					console.log('tanchuk');
				});
				// #endif
			},
			happenTimeFun(num) {
				//时间戳数据处理
				let date = new Date(num);
				//时间戳为10位需*1000，时间戳为13位的话不需乘1000
				let y = date.getFullYear();
				let MM = date.getMonth() + 1;
				MM = MM < 10 ? '0' + MM : MM; //月补0
				let d = date.getDate();
				d = d < 10 ? '0' + d : d; //天补0
				let h = date.getHours();
				h = h < 10 ? '0' + h : h; //小时补0
				let m = date.getMinutes();
				m = m < 10 ? '0' + m : m; //分钟补0
				let s = date.getSeconds();
				s = s < 10 ? '0' + s : s; //秒补0
				//return y + '-' + MM + '-' + d; //年月日
				return y + '-' + MM + '-' + d + ' ' + h + ':' + m; //年月日时分秒
			},
			cartlists: function() {
				var that = this;
				let data = {}
				// console.log("下标数据", that.cattab, that.swiperCurrent, that.swiperCurrents)
				if (that.cattab == 1) {
					if (that.swiperCurrent == 3) {
						data = {
							pgIndex: this.pageInfo.page,
							rowCount: this.pageInfo.size,
							kleixing: that.cattab - 1,
						}

					} else {
						data = {
							pgIndex: this.pageInfo.page,
							rowCount: this.pageInfo.size,
							kleixing: that.cattab - 1,
							kstatus: that.swiperCurrent,
						}
						console.log("data", data)

					}
				} else {
					if (that.swiperCurrents == 3) {
						data = {
							pgIndex: this.pageInfo.page,
							rowCount: this.pageInfo.size,
							kleixing: that.cattab - 1,
						}

					} else {
						data = {
							pgIndex: this.pageInfo.page,
							rowCount: this.pageInfo.size,
							kleixing: that.cattab - 1,
							kstatus: that.swiperCurrents,
						}

					}
				}

				that.https({
					url: cartlist_api,
					method: 'POST',
					header: {
						'content-type': 'application/json'
					},
					data: data,
					success: res => {
						console.log("cartList", res);

						// that.kalist = []; //普通卡全部
						// that.kalist_new = []; //最新-普通卡
						// that.kalist_no = []; //未使用
						// that.kalist_yonged = [] //已使用
						// that.superkalist = []; //全部超级卡列表
						// that.superkalist_new = []; //最新卡密-超级卡
						// that.superkalist_no = [];
						for (let i = 0; i < res.card_list.rows.length; i++) {

							var yesno = Number(res.card_list.rows[i].kstatus);

							var checks = false;
							var dischecks = false;
							var disable = false
							if (yesno == 0) {
								checks = false;
							} else if (yesno == 1) {
								checks = false;
							} else if (yesno == 2) {
								checks = false;
								dischecks = true;
								disable = true
							}
							if (yesno == 3) {
								checks = false;
								dischecks = true;
							}

							//console.log(dischecks);
							res.card_list.rows[i].checks = checks;

							res.card_list.rows[i].kchetrue = dischecks;

							res.card_list.rows[i].dischecks = dischecks;

							res.card_list.rows[i].ktime = that.happenTimeFun(res.card_list.rows[i].ktime);
							res.card_list.rows[i].kxtime = that.happenTimeFun(res.card_list.rows[i]
								.kxtime);

							if (res.card_list.rows[i].kleixing == 0) {
								//普通卡
								that.kalist.push(res.card_list.rows[i]);
								that.totalNum = that.kalist.length
								// that.kalist = [...that.kalist,...res.card_list.rows[i]]
								// that.kalist = that.kalist.concat(res.card_list.rows[i])

								if (res.card_list.rows[i].kstatus == 0) {
									that.kalist_new.push(res.card_list.rows[i]);
									that.totalNum = that.kalist_new.length
								}
								if (res.card_list.rows[i].kstatus == 1) {
									that.kalist_no.push(res.card_list.rows[i]);
									that.totalNum = that.kalist_no.length
								}
								if (res.card_list.rows[i].kstatus == 2) {
									that.kalist_yonged.push(res.card_list.rows[i]);
									that.totalNum = that.kalist_yonged.length
								}
							}
							// 
							if (res.card_list.rows[i].kleixing == 1) {
								//超级卡
								that.superkalist.push(res.card_list.rows[i]);
								if (res.card_list.rows[i].kstatus == 0) {
									that.superkalist_new.push(res.card_list.rows[i]);
									that.totalNum = that.superkalist_new.length
									console.log(that.totalNum, '888888');
								}

								if (res.card_list.rows[i].kstatus == 1) {
									that.superkalist_no.push(res.card_list.rows[i]);
									that.totalNum = that.superkalist_no.length
								}
								if (res.card_list.rows[i].kstatus == 2) {
									that.superkalist_yonged.push(res.card_list.rows[i]);
									that.totalNum = that.superkalist_yonged.length
								}
							}
						}

						console.log('kalist_new', that.kalist_new, '10000000000000000000');
						console.log("333333333333");
						return
						uni.hideLoading();
						that.jiazai = false;
						that.loadings = false;
						that.kalist = res.card_list; //全部
					},
					fail: err => {
						console.log(err);
						uni.hideLoading();
					}
				});
			},


			radioclik: function(num, value) {
				var that = this;
				console.log(num, value);
				if (that.radiock[num] == true) {
					that.radiock[num] = false;
				} else {
					that.radiock[num] = true;
				}
			},
			cart(num) {
				this.arr = []
				this.lengthL = 0
				console.log("卡类型", num)
				var that = this;
				// uni.reLaunch({
				// 	url:'./cart?cattab='+num
				// })
				that.cattab = num;
				that.swiperCurrent = 0
				that.swiperCurrents = 0
				that.cartlists()
			},
			reachBottom() {
				// 此tab为空数据
				console.log('jiazai');
				this.pageInfo.page++
				this.cartlists()
				// if(this.current != 2) {
				// 	this.loadStatus.splice(this.current,1,"loading")
				// 	setTimeout(() => {
				// 		this.getOrderList(this.current);
				// 	}, 1200);
				// }
			},
			// 页面数据
			getOrderList(idx) {
				// for (let i = 0; i < 5; i++) {
				// 	let index = this.$u.random(0, this.dataList.length - 1);
				// 	let data = JSON.parse(JSON.stringify(this.dataList[index]));
				// 	data.id = this.$u.guid();
				// 	this.orderList[idx].push(data);
				// }
				// this.loadStatus.splice(this.current, 1, 'loadmore');
			},

			// tab栏切换
			change(index) {
				this.arr = []
				this.lengthL = 0
				this.swiperCurrent = index;
				// console.log("index", index)
				this.cartlists()

				//this.getOrderList();
			},

			transition({
				detail: {
					dx
				}
			}) {
				this.$refs.tabs.setDx(dx);
			},
			animationfinish({
				detail: {
					current
				}
			}) {
				this.$refs.tabs.setFinishCurrent(current);
				this.swiperCurrent = current;
				this.current = current;
				this.cartlists()
			},
			/**
			 * 第二个选项卡
			 * */
			changes(index) {
				this.swiperCurrents = index;
				this.cartlists()
				console.log("index", index)
				this.lengthL = 0
				//this.getOrderList();
			},

			transitions(e) {
				let dx = e.detail.dx;
				this.$refs.uTabs.setDx(dx);
			},
			animationfinishs(e) {
				let current = e.detail.current;
				this.$refs.tabss.setFinishCurrent(current);
				this.swiperCurrents = current;
				this.currents = current;
				this.cartlists()
			}

		},
		onReachBottom() {

			console.log("上拉上拉上拉")

		},

	};
</script>

<style scoped lang="scss">
	page {
		background: #F7F7F7;
	}

	.dibu {
		width: 100%;
		height: 100rpx;
	}

	.bos {
		width: 100%;
		// height: 400rpx;
	}

	.footer {
		width: 750rpx;
		height: 80rpx;
		line-height: 80rpx;
		background: #ffffff;
		box-shadow: 10rpx 0rpx 5rpx 5rpx #d6d6d6;
		text-align: center;
		display: flex;
		position: fixed;
		left: 0;
		bottom: 0rpx;
	}

	.lojiazai {
		width: 700rpx;
		margin: 50rpx auto;
		text-align: center;
	}

	.footan {
		border-radius: 20rpx;
		display: inline-block;
		height: 60rpx;
		line-height: 60rpx;
		background: #8b8b8b;
		color: #ffffff;
		position: relative;
		margin-top: 10rpx;
	}

	.cartbg {
		background: #FFFFFF;
		width: 750rpx;
		margin: 0 auto;
	}

	.cartlist {
		width: 690rpx;
		height: 264rpx;
		background: #FFFFFF;
		border-radius: 20rpx 20rpx 20rpx 20rpx;
		opacity: 1;
		border: 2rpx solid #EFEFEF;
	}

	.cartlisttxt {
		display: inline-block;
		font-size: 22rpx;
	}

	.onoff {
		display: inline-block;
	}

	.cartrow {
		width: 750rpx;
		height: calc(100vh - 100rpx);
		display: block;

		.select-box {
			width: 690rpx;
			height: 70rpx;
			margin: 0 auto;
			display: flex;
			justify-content: space-between;
			margin-top: 30rpx;

			.select-all {
				font-size: 28rpx;
				font-family: PingFang SC-Regular, PingFang SC;
				font-weight: 400;
				color: #2B2B2B;
			}

			.select--right {
				font-size: 28rpx;
				font-family: PingFang SC-Regular, PingFang SC;
				font-weight: 400;
				color: #AAAAAA;
			}
		}

		.search-box {
			width: 690rpx;
			height: 80rpx;
			opacity: 1;
			margin: 30rpx auto;
			border-radius: 20rpx 20rpx 20rpx 20rpx;
			border: 2rpx solid #0DA0FF;
			position: relative;

			.search-input {
				width: 690rpx;
				position: absolute;
				left: -100rpx;
				color: #0DA0FF;

				.u-field.data-v-1c764f86 {
					color: #0DA0FF;
				}
			}

			.ss-img {
				width: 30rpx;
				height: 30rpx;
				position: absolute;
				top: 30rpx;
				left: 30rpx;
			}

			.search {
				display: inline-block;
				width: 136rpx;
				height: 58rpx;
				background: #0DA0FF;
				border-radius: 42rpx 42rpx 42rpx 42rpx;
				opacity: 1;
				font-size: 30rpx;
				font-family: PingFang SC-Medium, PingFang SC;
				font-weight: 500;
				color: #FFFFFF;
				line-height: 58rpx;
				position: absolute;
				top: 10rpx;
				right: 30rpx;
				text-align: center;
			}
		}
	}

	.cartbutton {
		width: 690rpx;
		display: block;
		margin: 0rpx auto;
		display: flex;
		flex-direction: row;
		align-items: center;
		text-align: center;
		justify-content: space-between;
		padding: 20rpx 0;
	}

	.cartbuttonview {
		width: 345rpx;
		height: 70rpx;
		line-height: 70rpx;
		background: #FFFFFF;
		display: inline-block;
		border-radius: 35rpx;
		background: #F8F9FB;
		font-weight: 500;
		color: #2B2B2B;
		font-family: PingFang SC-Medium, PingFang SC;
		/* border: 1rpx solid #ffffff; */
	}

	.action {
		background: #0DA0FF;
		display: inline-block;
		color: #ffffff;
		border: none;
	}

	.wrap {
		display: flex;
		flex-direction: column;
		height: calc(100vh - var(--window-top));
		width: 100%;
		overflow: hidden;
	}

	.swiper-box {
		flex: 1;
		height: 83vh;
		// height: calc(100vh - 240rpx - var(--window-top));
	}

	.swiper-item {
		height: 100%;
		overflow-y: scroll;
	}

	.page-box {
		width: 750rpx;
		height: 100%;
		margin: 0;
		padding: 0;
	}

	.attrsetting {
		width: 600rpx;
		height: 150rpx;
		position: relative;
		padding-top: 50rpx;
	}

	.arrtku {
		padding: 5rpx 10rpx;
		border-radius: 300rpx;
		max-width: 500rpx;
		background: #0bd34e;
		text-align: center;
		color: #ffffff;
		height: 80rpx;
		line-height: 80rpx;
		margin: 0 auto;
	}

	.attrbutton {
		display: flex;
		flex-direction: row;
		align-items: center;
		text-align: center;
		justify-content: space-between;
		width: 600rpx;
		height: 100rpx;
		padding-top: 50rpx;
	}

	.attrbuttonview {
		width: 200rpx;
		display: inline-block;
		border: solid 1rpx #0bd34e;
		color: #0bd34e;
		border-radius: 300rpx;
		height: 60rpx;
		line-height: 60rpx;
	}
</style>